WorldTransformation on pages with a high resolution.

  • Hello,

    we added wPDF to an existing application which draws several objects (Text, Lines, Pictures) on different output canvas (Screen, Metafile, Printer) and now wPDF.

    The typical page sizes created by this application are very large (width up to 320 mm and height up to 1000 mm).

    The application uses internally coordinates in 1/1000 mm. For the existing canvas types we call the SetWindowExtEx()-Function to set the dimensions of the canvas so we can directly draw with the internal coordinates.

    So we can draw with the existing functions on the wPFD canvas the StartPage() is called with xres, yres = 25400.

    This works perfect until we use SetWorldTransform() to rotate the device context to draw a single rotated object.

    On top of the page the objects are rotated, but not after approx. 250 mm in the lower right of the page.

    The EMF created in DebugMode is ok.

    Can we create the page in another way so we can use our existing code and the world transformation still works.

    Regards,

    Thomas

    • Offizieller Beitrag

    Coordinates in PDF are limited to 32000 by the PDF specs - so an xresd/yres of 25400 can cause a problem when you display the PDF on certain PDF readers which respect this limitation.

    So you needs to use a lower resolution and ModifyWorldTransform to scale your coordinates to the low res surface.

    Better avoid SetWorldTransform, it is a specialty supported by windows but not by PDF. (The transforms are always based on each other). Use SaveDC/RestoreDC to return to the unmodified world after you draw a rotateds object.

    If you use SetWorlkdsTransform wPDF has to create an inverse matrix which may not always give correct results because of rounding errors which cannot be avoided.

  • Hello,

    it's not possible to avoid SetWorldTransform in our application in all cases, because we call an external DLL which draws a barcode on the DC and sometimes this has to be rotated in 1° steps.

    When i modify your LowLevel-Demo to resolution = 25400 and StartPage()-Height = 40 * res a PDF with a PageHeight of 1.016 mm is created.

    Unrotated (untransformed) content at the bottom of the page is shown in Acrobat Reader DC and in the PDF are coordinates > 32000. e.g. a rectangle and a line:

    ET 1 0 0 1 0 0 cm 1 g 0 G 2 w 1 J 1 j [] 0 d 139700 -965200 71120 -43180 re S 139700 -990600 m 210820 -990600 l S

    So, without WorldTransform is everything ok, with WorldTransform the transformation operates correct until a certain y position.

    What is the purpose of the mode switches wpAlwaysHighResPDF, wpNeverHighResPDF? I can't see a difference in the created PDF code.

  • Hello,

    one further amendment:

    We also use the WorldTransformation for mirror printing (reflection in the XFORM structure).

    When i combine multiple transformations with these actions, the rotation is ok on every position if the page:

    1. Mirror/Reflection with SetWorldTransformation()

    2. Several rotations with ModifyWorldTransformation() + SaveDC/RestoreDC across the whole page

  • Hello,

    now i have a work around:

    1. If no global transformation exists (no mirror print) then create a dummy transformation with the default values for the XFORM structure

    2. Rotate single objects via ModifyWorldTransformation()