I´ve came across a challenge of creating a trimbox in a PDF with portrait orientation and them rotate it to the landscape orientation, that i did.
pageDict.put(PdfName.ROTATE, new PdfNumber(rot + 270));
But my trimbox goes banana. When i define it again with the same coordinates and with the rotation that i defined the trimbox have the same look (perimeter) but the isn´t in the same place.
I´ve tried to define the trimbox calculating the new coordinates but the calculation don´t make much sense, because the calculations (supposed) are ok but the trimbox don´t appear in the place that was defined in the portrait orientation.
Say that i want to define a trimbox in portrait, say that inside is a picture, and when i rotate the page the trimbox continues to involve the same picture, how can this be done?
Anyone have any idea?
cheers
UPDATED:
This is the original TrimBox setted:
This is the TrimBox after doing the rotation of the PDF page:
What i want is to set keep the same TrimBox and in the same place independent if the page is rotated or not.
Cheers
UPDATED:
The rotation of the PDF is in the original POST.
The definition of the TrimBox is made by BIRT with a changed API made by us that defines the boxes, one is TrimBox and is made like this:
PdfArray array = (PdfArray) pageDict.get(PdfName.TRIMBOX);
PdfRectangle trimBox = new PdfRectangle(Float.parseFloat(array.getArrayList().get(0).toString()),Float.parseFloat(array.getArrayList().get(1).toString()),Float.parseFloat(array.getArrayList().get(2).toString()), Float.parseFloat(array.getArrayList().get(3).toString()));
pageDict.put(PdfName.TRIMBOX, trimBox);
About providing the files, i can´t because Stack don´t let me (need at least 10 reputation).
Cheers
UPDATED:
Original file
PDF file after rotation
Because of the reputation(only 2 links) i remove the image links.
I just compared the two files you provided in Adobe Acrobat. And it appears that the PDFs are just as they should be.
Test_Original.pdf:
Entries in page dictionary:
/MediaBox [0, 0, 666.29, 912.89]
/TrimBox [22, 22, 600, 400]
/BleedBox [22, 22, 600, 400]
/ArtBox [22, 22, 600, 400]
In Adobe Acrobat:
Test_After_ROTATED.pdf:
Entries in page dictionary:
/TrimBox [22, 22, 600, 400]
/MediaBox [0, 0, 666.29, 912.89]
/BleedBox [22, 22, 600, 400]
/ArtBox [22, 22, 600, 400]
/Rotate 270
In Adobe Acrobat:
Thus, everything is just fine, only the rotate was added in the page dictionary and, therefore, everything (including the trim box) is rotated.
Thus, I assume the program you use to display the trim box is somewhat limited when rotation is part of the game.
You mentioned BIRT. Maybe BIRT has its own set of information concerning the trim box stored somewhere else (according to the screenshots you used to have in your question with distances from top, left, right, and bottom). In that case those information might also have to be updated when rotating the PDF.
Or, as you use a changed API made by you that defines the boxes, maybe that API has to be told about rotation effects?
Related
I am designing a map in Mapbox Studio, using mapbox.mapbox-terrain-v2’s contour layer to determine the contour lines. This is based on the outdoors style.
In the outdoors style, the contour labels are oriented so that the text is displayed between -90° and 90° of horizontal, because Keep Text Upright is set. If I disable this, then the text becomes oriented at any angle. However, this text is oriented at exactly the opposite angle to what I would like: it always points downhill, not uphill. See first image below: note that the numbers are upright where the elevation increases from north to south.
What I am aiming for is to use the Ordnance Survey style of orienting numbers uphill (upright where the elevation increases from south to north), as in the second image below.
My current style can be seen here. I have tried using the text-rotate field, but this rotates each character individually, and there does not appear to be a function to reverse the string to counteract this. Additionally, this rotates about the top of each letter, meaning that the result is offset from the actual contour line, and text-translate + text-translate-anchor seem unable to resolve this.
As you noticed, using text-rotate on a symbol layer with placement: line rotates each character individually. So you would need to then reverse the string, which isn't possible within the expressions available.
However. There is one hacky workaround which may solve the problem for you. You can simply hardcode all the possible elevations with their reversals:
["match", ["get", "ele"],
750, "m057",
700, "m007",
650, "m056",
600, "m006",
550, "m055",
500, "m005",
""
]
Combined with a text-offset of 0,1.5, this actually looks alright:
I've published the style here
I am reading an existing PDF file into a new PDF file, and scaling the first page based on the page dimensions. The page gets scaled to 90-95% in order to make room for some footer text. The problem I have is that the resulting scaled page leaves white space at the top of the page, NOT the bottom. Is there a way to control the results so that they start in the top left of the page and not the bottom left?
Here's my code that adds the scaled page:
cb.AddTemplate(importedPage, scaleSize, 0, 0, scaleSize, 5, 20);
Object "cb" is a PDFContentByte class, while "scaleSize" is a float set to .9 or .95. The scaling works great, but the positioning is an issue. Thanks!
figured it out: the value of "20" for the final parameter was incorrect. A value of 100 is far more suitable for my purposes, and now I understand far better the coordinate system in PDF/iText. For those interested, the 0, 0 point for a PDF document is the lower left corner.
I'm using Dojo for drawing my charts. I need to draw an overlay at certain points. Almost like a tooltip that’s always shows. It can be a stack of values or an icon that display above, below or next to the data-point.
Does anyone know how I can accomplish this?
Does anyone know how I can access the list of screen coordinates for each plotted data-point?
My theory is; if there is no way to draw a persistent and custom tooltip, to draw over the chart and position my custom object in relation to the point coordinate.
Another option would be to draw a custom marker. (Not like the normal SVG paths.)
Please don’t suggest another charting library. I need to know how to do this in Dojo.
Thanks in advance.
I am not sure if you already have found an answer to using custom markers. I am using the SVG path variable for plotting the custom marker.
For eg:
var custom_marker = "M150 0 L75 200 L225 200 Z" // a triangle
var data = [{x: 10, y: 20, marker: custom_marker}, {x: 15, y: 25, marker: custom_marker}] // and so on
Feed this data into dojo chart and you can plot the custom marker.
I'm trying to position a button.
Here is the code for the positioning..
[btnAbs setFrame:CGRectMake(57, 50, 106, 99)];
The coordinates I got are from here:
As you can see the xib stats the x & y to be at 57 and 192, which is where I want the button to be.
However when I run it in simulator, here is where its placed:
Obviously i could keep guessing and guessing the x and y coordinates, but this is very time consuming. So how come it's doing this?
Please join the links together when looking at the pics as i need more than 10 reps to post images, or a mod fix this please?
The problem is here:
The “origin” in Interface Builder doesn’t actually affect how the view gets positioned programmatically—it’s just a visual aid. If you click the dot in the top left of that box, the X and Y coordinates will change to the top-left of the view, which are the coordinates you want to pass to -setFrame:.
It looks to me as if you have the GUI designer aligning base upon the center center of your image view. When you do it in code, it is going to align based upon the top left of the image view.
Further, your code places it at a y of 50, where your GUI designer is showing a y coord. of 192.
I might be overlooking this, but how can one get the size of a PDF if you're using FastPDFKit?
I'm trying to create PNG's from a pdf, but without knowing the actual dimensions of the page it's rather hard to get it right.
EDIT:
I searching in the documentation before, but all I found was this method:
- (void)getCropbox:(CGRect *)cropbox andRotation:(int *)rotation forPageNumber:(NSInteger)pageNumber withBuffer:(BOOL)withOrWithout
But I have no idea how to use it, it doesn't return anything.
Not sure how familiar you are with PDF, but each page specifies a number of "boxes" that are various rectangles of interest (crop, media, etc)
Most apps using PDF elect to use the crop box which defines the region of the page that should be displayed. (See section 10.10.1 of the PDF 1.7 specification: http://www.adobe.com/devnet/pdf/pdf_reference_archive.html)
Also of note is that a page can specify a rotation angle of 0, 90, 180, or 270 which you need to apply to the crop box yourself. (see /Rotate in table TABLE 3.27 of the PDF 1.7 spec)
So using the above API you would call it like so:
[somePDFDoc getCropbox:&cropbox andRotation:&rotation forPageNumber:10 withBuffer:NO];
This would give you the cropbox rect and it's rotation.
NOTE: I have never used FastPDFKit
NOTE2: If the value of cropbox is CGRectZero, you want to use one of the other rects. Most viewers use the media box instead.