How do I set the display area in PDFLIB - area

When I set the PDF paper size to A4, is there a way to make the PDF display area only A5 size while keeping the PDF paper size to A4?
Parts of text or images larger than A5 will not be displayed.
I have try the option 'CropBox',but it's make A4 size to A5 size.
please help me !!

you could clip the content by first creating a clipping path. This could look like:
p.being_page_ext(595, 842, "");
p.save();
p.rect(0, 0, 421, 595);
p.clip();
... (place content which will only visible within the A5 area)
p.restore()
... further content which will be visible on the whole page.
p.end_page_ext("");
I added the save()/restore(), so you can encapsulate the clipping and can add additional content afterwards. Please adjust also the reference point for the clipping rectangle if necessary.
Please see PDFlib 9.3 Tutorial, chapter 3.2.3 "Direct Paths and Path Objects" for details.

Related

Why are my table border look weird in PDF viewers?

I generated a table with iText7 (C#):
var cell = new Cell().Add(new Paragraph(headers[c]).SetFont(font).SetFontColor(ColorConstants.WHITE).SetFontSize(size).SetBold());
cell.SetBackgroundColor(color);
cell.SetTextAlignment(iText.Layout.Properties.TextAlignment.CENTER);
cell.SetPadding(0);
cell.SetBorder(new SolidBorder(1));
table.AddCell(cell);
Document has the table, but on certain scalings, it looks weird on the edges:
Taking a closer look on the image above:
If however I change the zoom in the viewer directly, it looks OK:
How do I get rid of these unnecessary parts from the border?
I'm attaching here the resulted PDF for reference:
Download sample PDF
I also noticed that on iText KB pages, there is this kind of behavior:
https://kb.itextpdf.com/home/it7kb/faq/how-do-i-change-the-border-color-of-a-pdfpcell
See the red and blue bars' left edges:
This behaviour is not uncommon in PDF or other print drivers where vectors are printed rather than plotter definitions (often called "Dangles". It would be worse if the definition was rounded or square, rather than butt, and join as "mitre" cannot apply, see below). The overlap is intentional (to ensure both lines are inclusive). In a laser drum print that may be desirable overkill, but disastrous for any inkjet or screen. It looks like the cell is not bordered by a box, but using common straight vectors. Again this is often desirable optimisation but not when the weight is not honoured. Thus it depends if the viewer is using the correct thickness.
All desktop PDF viewers (icluding Chrome and FireFox) I tested showed the lines correctly as clean overlap without "Dangles". Acrobat has a reputation for undesirably thickening or thinning its standard defined lines depending on its user settings.

How to convert xlsx to pdf on one page

I have a 13 column xlsx and I want convert to pdf.
I use this code: "soffice" ,"--headless","--convert-to", "pdf" , filepath ,"--outdir",outpath.
I can convert to pdf but the columns too many so they have been showed on four pages.
I need they show on one page.
And it show on straight , I need it show on horizontal.
Thanks
XLSX printout settings (PDF export) are part of the file contents so here is the same file saved with different settings but same export command. (convert-to implies headless, so not generally needed. The author decides a cell content and shape and also sets how many rows and columns will fit in a standard page such as A4 portrait or A4 Landscape etc. Thus only a macro can change print layout area. The best that may be possible externally is to scale it up or down on to bigger or smaller paper.
soffice --convert-to pdf:calc_pdf_Export "DataTables example Default.xlsx"
soffice --convert-to pdf:calc_pdf_Export "DataTables example A3.xlsx"
You need to change layout for printing and export in the preview screen if you want 13 columns you set area from A:1 to M:Y where Y is your desired number of lines (whatever their variable height may be.)

How can I split an image into multiple files with an action in photoshop?

I use Stamps.com to print shipping labels that are 2.4" wide. Stamps.com unfortunately will only generate a pdf of this size label with 4 labels on the sheet. It is not paginated, and will not print sequentially. Their template assumes you will print it out on an 8.5" x 11" label sheet and peel off from there. Four Label 8.5x`11 sheet
I want to print on a thermal, continuous roll printer which cuts each label out automatically. To have this work I need each label to be one page, and the pdf with four labels split into four cropped files of 2.4" x 8.5". Any ideas?
I have failed so far in making an action in both acrobat, and photoshop. Should I be looking into solving this programmatically outside of photoshop?
I would be inclined to do that with ImageMagick which is installed on most Linux distros and is available for OSX and Windows.
Unfortunately, you haven't provided a sensible sample image, so I'll provide a fake one. I have made the border yellow intentionally so you can see it on StackOverflow's white page layout.
Just at the command line in the Terminal, you would want to set the default density so that when ImageMagick rasterises the image it retains its quality. The [0] refers to the first page of the PDF. Then you would want to trim off the border - whatever colour it is (+/- a small fuzz factor to allow for variations in image encoding) and then tile into 4 equal horizontal strips. So, your command would be:
convert -density 240 stamps.pdf[0] fuzz 20% -trim -crop x4# f-%d.jpg
and you will get 4 files out, called f-0.jpg, f-1.jpg, f-2.jpg and f-3.jpg

itext correctly get each image position within page or document

Experimenting with itext I am extracting both text and images from pdf files. For my purpose I build an html file using the text and images. The goal is to place the extracted images throughout the text rather than placing them at the end as I do currently.
After some research itext renderInfo.getImageCTM() appears to be just what I need, however the coordinates returned do not resemble the positions of some of the images when comparing to what's being displayed in adobe reader.
My MyImageRenderListener class has this
Matrix matrix = renderInfo.getImageCTM();
float x = matrix.get(Matrix.I31);
float y = matrix.get(Matrix.I32);
Which should give me the XY, top left hand corner position of each image, if I've understood it correctly.
Here is the pdf file I will be referring to
It's a 4 page PDF that contains either one or two images per page.
PAGE X Y
Page1 33.0 358.5
Page2 1st 321.7 419.9
Page2 2nd 41.2 182
Page3 1st 43.1 307.5
Page3 2nd 417 58.5
Page4 292.5 457.5
When comparing the coordinates output to the actual document the numbers do not seem to make sense. For example, On page3, the second image Y (58.5) is lower than the first image Y (307.5) on the same page. That would put image 2 on page 3 before image 1??
Also none of the Y and some of the X coordinates appear to be correct when comparing to the layout in any reader.
What am I getting wrong or miss understanding please?

PostScript on a Dymo labelwriter

I'm trying to print a postscript file to a Dymo LabelWriter (tried a LabelWriter 450 and LabelWriter 330-Turbo), i'm getting it trough ok, but the margin seems to be way to high, 1/3 of the label isn't printable (see pic, the black square is supposed to cover the entire label over the width).
The label is 89mm on 39mm (so 252pt x 123pt)
I'm using a boundig box of 8 8 252 123 and the page orientation is set to portrait.
I even tested it with an eps-file generated from Gimp, it leaves the same area blank.
anyone has an idea why it isn't printing correctly?
EDIT:
The file can be viewed here : http://pastebin.com/c7YC5ftb
The command I use to print it on a Dymo LabelWriter is:
C:\ps\gswin32c.exe -sDEVICE=mswinpr2 -dNoCancel -dNOPAUSE -dSAFER -sOutputFile="%%printer%%DYMO LabelWriter 450" -q "C:\ps\dymo.ps" -c quit
Not without seeing the PostScript file, no. I don't see from the Dymo web site that the printer accepts PostScript input, so how are you sending the PostScript file to it ?
Added in response to edits in the question.
Well its not absolutely clear to me what you expect this to look like.
Your original comment refers to a black square, but the PostScript doesn't contain a black square, it draws a rectangle with an aspect ratio of 20:1. You have set the media up to be wider than it is long (252,123) but you then use the Orientation to rotate the content by 270 degrees. Its true this is portrait, but upside down. If you want portrait why not just set the media to be portrait ?
Simply put the origin is the corner directly above your thumb in the photograph, and I think the long and short sides of the print are reversed with respect to the actual label.
Note that the BoundingBox comment is a comment and is ignored by the PostScript interpreter so changing it has no effect.
Perhaps if you could explain what you are trying to achieve ?
Problem is solved, the printer wasn't set to accept this type of labels
If you ever have this problem go the advanced settings of your printer driver and set the label.

Resources