From 5d5aa5cf1714af3ed471ab6302c79e7bb5e3e0d7 Mon Sep 17 00:00:00 2001 From: Joseph Argento Date: Wed, 11 Sep 2024 16:08:39 -0500 Subject: [PATCH 1/2] Fix sample code based on improved usage of Image.Translate(). The imaging code of the .NET and Java libraries has been updated significantly and now Image.Translate() takes coordinates as one would expect on the page. Whereas previously the values were based on internally applying the matrix multiplication backwards. Because of this change the sample needs to be updated to produce the correct output. --- .../ExtendedGraphicStates.cs | 38 +++++++++++++------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/ContentModification/ExtendedGraphicStates/ExtendedGraphicStates.cs b/ContentModification/ExtendedGraphicStates/ExtendedGraphicStates.cs index c71669f..5904749 100644 --- a/ContentModification/ExtendedGraphicStates/ExtendedGraphicStates.cs +++ b/ContentModification/ExtendedGraphicStates/ExtendedGraphicStates.cs @@ -1,7 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Text; using Datalogics.PDFL; +using System; /* * @@ -12,7 +10,7 @@ * * This sample program shows how to use the Extended Graphic State object to add graphics parameters to an image. * - * Copyright (c) 2007-2023, Datalogics, Inc. All rights reserved. + * Copyright (c) 2007-2024, Datalogics, Inc. All rights reserved. * */ @@ -37,6 +35,9 @@ static void blendPage(Document doc, Image foregroundImage, Image backgroundImage gsText.FillColor = new Color(0, 0, 1.0); TextState ts = new TextState(); + double spaceFactor = 18.0; + double heightOffset = height - 88.0; + for (int i = 0; i < 16; i++) { Image individualForegroundImage = foregroundImage.Clone(); @@ -44,15 +45,24 @@ static void blendPage(Document doc, Image foregroundImage, Image backgroundImage GraphicState gs = individualForegroundImage.GraphicState; individualForegroundImage.Scale(0.125, 0.125); - individualForegroundImage.Translate(800, 200 + height * (7 - i)); individualBackgroundImage.Scale(0.125, 0.125); - individualBackgroundImage.Translate(800, 200 + height * (7 - i)); - // Halfway through, create 2nd column by shifting over and up + spaceFactor = 18.0; + if (i == 0) + { + spaceFactor = 0; + } + + //Halfway through, create 2nd column by shifting over and up if (i > 7) { - individualForegroundImage.Translate(2400, height * 8); - individualBackgroundImage.Translate(2400, height * 8); + individualForegroundImage.Translate(400, heightOffset - (72.0 + spaceFactor) * (i - 8)); + individualBackgroundImage.Translate(400, heightOffset - (72.0 + spaceFactor) * (i - 8)); + } + else + { + individualForegroundImage.Translate(100, heightOffset - (72.0 + spaceFactor) * i); + individualBackgroundImage.Translate(100, heightOffset - (72.0 + spaceFactor) * i); } docpage.Content.AddElement(individualBackgroundImage); @@ -62,9 +72,14 @@ static void blendPage(Document doc, Image foregroundImage, Image backgroundImage Matrix m = new Matrix(); if (i > 7) - m = m.Translate(480, 750 - ((i - 8) * 100)); // second column + { + m = m.Translate(480, heightOffset - (72.0 + spaceFactor) * (i - 8));// second column + } else - m = m.Translate(180, 750 - (i * 100)); // first column + { + m = m.Translate(180, heightOffset - (72.0 + spaceFactor) * i);// first column + } + m = m.Scale(12.0, 12.0); ExtendedGraphicState xgs = new ExtendedGraphicState(); @@ -193,7 +208,6 @@ static void Main(string[] args) doc.EmbedFonts(); doc.Save(SaveFlags.Full, sOutput); - } } } From 984620944601af6f9da314b9e9b745c7387c92a1 Mon Sep 17 00:00:00 2001 From: Joseph Argento Date: Fri, 25 Oct 2024 10:47:39 -0500 Subject: [PATCH 2/2] Fix link so it's not just the raw URL. Clarify a statement about FE and samples. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index bb77150..b14b13c 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,9 @@ Most of the code samples in APDFL are designed to demonstrate how an API works b We assume a basic level of technical understanding of the PDF file format, invidual sample category directory markdown files go into more details. -Many of these sample programs automatically generate an output file or set of files. These output files, generally PDF or graphics files (JPG or BMP), are stored in the directory where the application has been run. If you run a sample program a second or third time, it will overwrite any output files that were created and stored earlier. However, if you run a sample program, generate a PDF output file, and then open that PDF file and try to run that sample program again, you will see an error message. The program will not be able to overwrite an existing output file if that file is currently open in another program. +Many of these sample programs generate an output file or set of files. These output files, generally PDF or graphics files (JPG or BMP), are stored in the directory where the application has been run. If you run a sample program a second or third time, it will overwrite any output files that were created and stored earlier. However, if you run a sample program, generate a PDF output file, and then open that PDF file and try to run that sample program again, you will see an error message. The program will not be able to overwrite an existing output file if that file is currently open in another program. -*(Note: that the Forms Extension product and samples are available by talking to Datalogics Sales.)* +*(Note: that the Forms Extension product is available by talking to Datalogics Sales.)* ## ***Building and Running Samples*** Samples can be built and run easily in an IDE such as Visual Studio 2017, 2019, or 2022. @@ -23,7 +23,7 @@ Samples can be built and run easily in an IDE such as Visual Studio 2017, 2019, ## Free trial & license activation To activate the free trial: -1. Visit https://www.datalogics.com/pdf-sdk-free-trial to obtain an activation key. +1. Visit [Free Trial](https://www.datalogics.com/pdf-sdk-free-trial) to obtain an activation key. 2. A prompt will appear on your console when executing Datalogics sample code. Alternatively, to use an activation key in code, the LicenseKey member of the Library class can be set to