From 2cb6201850a1a6185f7efc9ed8b9e35cff7b66f8 Mon Sep 17 00:00:00 2001 From: Rob Lyman Date: Thu, 13 Aug 2026 16:24:18 -0500 Subject: [PATCH 1/5] Introduce a CreateDocFromWebPage sample to the repo This is a first draft at a CreateDocFromWebPage Java sample, complete with accompanying pom.xml. --- .../CreateDocFromWebPage/pom.xml | 216 ++++++++++++++++++ .../pdfl/samples/CreateDocFromWebPage.java | 100 ++++++++ 2 files changed, 316 insertions(+) create mode 100644 DocumentConversion/CreateDocFromWebPage/pom.xml create mode 100644 DocumentConversion/CreateDocFromWebPage/src/main/java/com/datalogics/pdfl/samples/CreateDocFromWebPage.java diff --git a/DocumentConversion/CreateDocFromWebPage/pom.xml b/DocumentConversion/CreateDocFromWebPage/pom.xml new file mode 100644 index 00000000..90ee0352 --- /dev/null +++ b/DocumentConversion/CreateDocFromWebPage/pom.xml @@ -0,0 +1,216 @@ + + + 4.0.0 + com.datalogics.pdfl.samples + CreateDocFromWebPage + 1.0-SNAPSHOT + + 17 + 17 + + + + + Windows64 + + + windows + amd64 + + + + win-x86-64-jni + + + + MacArm + + + mac + aarch64 + + + + mac-arm-64-jni + + + + Linux64 + + + + Linux + amd64 + + + + linux-x86-64-jni + + + + WindowsArm64 + + + windows + aarch64 + + + + win-arm-64-jni + + + + LinuxArm64 + + + + Linux + aarch64 + + + + linux-arm-64-jni + + + + + + com.datalogics.pdfl + pdfl + [21.0,22.0) + pom + + + com.datalogics.pdfl + pdfl + [21.0,22.0) + + + com.datalogics.pdfl + pdfl + [21.0,22.0) + zip + ${jni.classifier} + + + com.datalogics.pdfl + pdfl + [21.0,22.0) + zip + resources + + + com.datalogics.pdfl + pdfl + [21.0,22.0) + javadoc + + + + com.datalogics.pdfl + web-conversion-cef-runtime + [21.0,22.0) + zip + ${jni.classifier} + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 3.0.2 + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + unpack-resources + generate-resources + + unpack-dependencies + + + com.datalogics.pdfl + pdfl + resources + zip + ${project.build.directory}/lib/Resources + + + + unpack-jni + generate-resources + + unpack-dependencies + + + com.datalogics.pdfl + pdfl + ${jni.classifier} + zip + ${project.build.directory}/lib + + + + + unpack-web-conversion-runtime + generate-resources + + unpack-dependencies + + + com.datalogics.pdfl + web-conversion-cef-runtime + ${jni.classifier} + zip + ${project.build.directory}/lib + + + + + + maven-assembly-plugin + + + package + + single + + + + + + + true + com.datalogics.pdfl.samples.CreateDocFromWebPage + + + + jar-with-dependencies + + + + + + diff --git a/DocumentConversion/CreateDocFromWebPage/src/main/java/com/datalogics/pdfl/samples/CreateDocFromWebPage.java b/DocumentConversion/CreateDocFromWebPage/src/main/java/com/datalogics/pdfl/samples/CreateDocFromWebPage.java new file mode 100644 index 00000000..1b569e76 --- /dev/null +++ b/DocumentConversion/CreateDocFromWebPage/src/main/java/com/datalogics/pdfl/samples/CreateDocFromWebPage.java @@ -0,0 +1,100 @@ +package com.datalogics.pdfl.samples; + +import java.util.EnumSet; + +import com.datalogics.PDFL.Document; +import com.datalogics.PDFL.Library; +import com.datalogics.PDFL.SaveFlags; +import com.datalogics.PDFL.WebConvertInfo; +import com.datalogics.PDFL.WebPageOrientation; +import com.datalogics.PDFL.WebPageSize; +import com.datalogics.PDFL.WebToPDFConvertParams; +import com.datalogics.PDFL.WebViewportPreset; + +/* + * This sample demonstrates converting a web page or a local HTML file into a + * PDF document. + * + * The optional first argument may be a URL (http://, https://, or file://) or a + * path to a local HTML file. The sample detects which from the scheme prefix + * and calls Document.fromWebUrl or Document.fromHtmlFile accordingly. Relative + * asset references in a local file resolve against that file's directory. The + * optional second argument names the output file. + * + * Rendering is performed by the WebToPDF plugin, which embeds Chromium. That + * plugin runtime ships as a separate add-on package; see pom.xml, which declares + * it and unpacks it alongside the JNI libraries. + * + * Copyright (c) 2026, Datalogics, Inc. All rights reserved. + * + */ + +public class CreateDocFromWebPage { + + /** + * Returns true if the argument looks like a URL the conversion plugin + * handles natively, rather than a local filesystem path. + */ + private static boolean looksLikeUrl(String s) { + return s.startsWith("http://") || s.startsWith("https://") || s.startsWith("file://"); + } + + /** + * @param args optional source (URL or HTML file path) and output PDF path + */ + public static void main(String[] args) throws Throwable { + System.out.println("CreateDocFromWebPage sample:"); + + Library lib = new Library(); + + try { + String source = args.length > 0 ? args[0] : "https://www.datalogics.com"; + String output = args.length > 1 ? args[1] : "CreateDocFromWebPage-out.pdf"; + + // Conversion parameters + WebToPDFConvertParams params = new WebToPDFConvertParams(); + params.setViewportSize(WebViewportPreset.DESKTOP); + params.setPageSize(WebPageSize.LETTER); + params.setPageOrientation(WebPageOrientation.PORTRAIT); + params.setMargins(0.5, 0.5, 0.5, 0.5); + params.setPrintBackground(true); + params.setTimeoutSeconds(60); // 0 uses the 300s plugin default; -1 waits forever + + WebConvertInfo info = new WebConvertInfo(); + + final boolean isUrl = looksLikeUrl(source); + System.out.println("Converting " + (isUrl ? "URL " : "HTML file ") + source + " ..."); + + Document doc = isUrl + ? Document.fromWebUrl(source, params, info) + : Document.fromHtmlFile(source, params, info); + + System.out.println("Wrote " + info.getPageCount() + " pages in " + + info.getConversionTimeMs() + " ms"); + if (!info.getTitle().isEmpty()) { + System.out.println("Title: " + info.getTitle()); + } + // getSourceUrl reports the URL actually rendered, so it reflects any + // redirects the browser followed. + if (!info.getSourceUrl().isEmpty() && !info.getSourceUrl().equals(source)) { + System.out.println("Resolved URL: " + info.getSourceUrl()); + } + + System.out.println("Saving the document..."); + doc.save(EnumSet.of(SaveFlags.FULL), output); + System.out.println("Saved to " + output); + } + catch (RuntimeException e) { + // Web conversion failures surface as a plain RuntimeException: the + // interface layer's error category and plugin result code are not + // exposed to Java, so only the message text is available here. + System.err.println("Conversion failed: " + e.getMessage()); + System.err.println("If the plugin could not be loaded, confirm that the web " + + "conversion runtime was unpacked into target/lib (see pom.xml)."); + throw e; + } + finally { + lib.delete(); + } + } +} From dbd7bd9b6ca83002d87d76cffbbb1248de3afd5d Mon Sep 17 00:00:00 2001 From: Rob Lyman Date: Mon, 17 Aug 2026 11:59:22 -0500 Subject: [PATCH 2/5] Add run configuration for CreateDocFromWebPage sample This should have been added to the last commit. --- .../runConfigurations/CreateDocFromWebPage.xml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 DocumentConversion/CreateDocFromWebPage/.idea/runConfigurations/CreateDocFromWebPage.xml diff --git a/DocumentConversion/CreateDocFromWebPage/.idea/runConfigurations/CreateDocFromWebPage.xml b/DocumentConversion/CreateDocFromWebPage/.idea/runConfigurations/CreateDocFromWebPage.xml new file mode 100644 index 00000000..dfcc6a4a --- /dev/null +++ b/DocumentConversion/CreateDocFromWebPage/.idea/runConfigurations/CreateDocFromWebPage.xml @@ -0,0 +1,14 @@ + + + + + + + From 072e21aa1c1379d1aa203b5a0b8e34deb715bb04 Mon Sep 17 00:00:00 2001 From: Rob Lyman Date: Mon, 17 Aug 2026 13:25:00 -0500 Subject: [PATCH 3/5] Register CreateDocFromWebPage in the CI samples list The CI stages iterate samples_list, so the sample was previously skipped entirely by clean-samples, build-samples and run-samples: PR-145 passed without ever compiling it. No platform skip is needed. The WebToPDF plugin is published for all five platforms the samples matrix covers (Windows x64/ARM64, Linux x86_64/ARM64 and Apple-silicon macOS). --- tasks.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks.py b/tasks.py index b063ab29..626025f4 100644 --- a/tasks.py +++ b/tasks.py @@ -43,6 +43,7 @@ 'ContentModification/Watermark/', 'DocumentConversion/ColorConvertDocument/', 'DocumentConversion/ConvertToOffice/', + 'DocumentConversion/CreateDocFromWebPage/', 'DocumentConversion/CreateDocFromXPS/', 'DocumentConversion/FacturXConverter/', 'DocumentConversion/PDFAConverter/', From 5841a6b3e643a6260ff7bd0868274be57042832f Mon Sep 17 00:00:00 2001 From: Rob Lyman Date: Tue, 18 Aug 2026 14:52:46 -0500 Subject: [PATCH 4/5] Depend on the web-conversion plugin artifact, not just the CEF runtime The sample declared only web-conversion-cef-runtime, which on Windows and Linux carries the Chromium runtime alone. The plugin itself -- the DL210WebToPDF.ppi and its helper and server executables -- ships in the separate web-conversion artifact, which was never declared, so those platforms unpacked CEF with no plugin for APDFL to load and failed at conversion with "WebToPDF plugin HFT not found". macOS is the exception. There the .ppi is a single signed framework bundle with CEF embedded and cannot be split, so it ships whole inside web-conversion-cef-runtime and web-conversion publishes no mac-arm-64 classifier at all. Requesting one unconditionally would fail resolution, so the dependency sits in a profile that activates everywhere except mac. Both halves unpack through one execution into target/lib. Co-location is required rather than convenient: the CEF host runs out of process and is resolved relative to the loaded plugin, so plugin, runtime and JNI libraries have to share a directory. Verified in an isolated local repository that the Linux classifier yields the complete set -- plugin, both helpers, libcef and the CEF data files -- and that the helper and server executables retain their execute bits through the zip round trip. Co-Authored-By: Claude Opus 5 (1M context) --- .../CreateDocFromWebPage/pom.xml | 56 +++++++++++++++---- 1 file changed, 46 insertions(+), 10 deletions(-) diff --git a/DocumentConversion/CreateDocFromWebPage/pom.xml b/DocumentConversion/CreateDocFromWebPage/pom.xml index 90ee0352..d9f30bd6 100644 --- a/DocumentConversion/CreateDocFromWebPage/pom.xml +++ b/DocumentConversion/CreateDocFromWebPage/pom.xml @@ -77,6 +77,31 @@ linux-arm-64-jni + + + WebConversionPlugin + + + !mac + + + + + com.datalogics.pdfl + web-conversion + [21.0,22.0) + zip + ${jni.classifier} + + + @@ -111,10 +136,15 @@ javadoc com.datalogics.pdfl @@ -168,20 +198,26 @@ - unpack-web-conversion-runtime + unpack-web-conversion generate-resources unpack-dependencies com.datalogics.pdfl - web-conversion-cef-runtime + web-conversion,web-conversion-cef-runtime ${jni.classifier} zip ${project.build.directory}/lib From 09a94f1ad4513c948cce469a436cd60512bd028a Mon Sep 17 00:00:00 2001 From: Rob Lyman Date: Wed, 19 Aug 2026 14:30:35 -0500 Subject: [PATCH 5/5] Simplify code comments. Reduce overly verbose comments from Claude AI. --- .../CreateDocFromWebPage/pom.xml | 30 ++----------------- .../pdfl/samples/CreateDocFromWebPage.java | 9 ++---- 2 files changed, 5 insertions(+), 34 deletions(-) diff --git a/DocumentConversion/CreateDocFromWebPage/pom.xml b/DocumentConversion/CreateDocFromWebPage/pom.xml index d9f30bd6..fb497459 100644 --- a/DocumentConversion/CreateDocFromWebPage/pom.xml +++ b/DocumentConversion/CreateDocFromWebPage/pom.xml @@ -9,12 +9,6 @@ 17 - Windows64 @@ -81,9 +75,7 @@ The web-conversion plugin zip (DL210WebToPDF.ppi plus its helper and server executables) is published for Windows and Linux only. On macOS the plugin is part of the signed .ppi framework bundle that ships inside - web-conversion-cef-runtime, so there is no mac-arm-64 classifier to request; - declaring one unconditionally would fail dependency resolution on macOS. - Hence this dependency lives in a profile that activates everywhere but mac. + web-conversion-cef-runtime. --> WebConversionPlugin @@ -135,17 +127,6 @@ [21.0,22.0) javadoc - com.datalogics.pdfl web-conversion-cef-runtime @@ -200,14 +181,7 @@ unpack-web-conversion diff --git a/DocumentConversion/CreateDocFromWebPage/src/main/java/com/datalogics/pdfl/samples/CreateDocFromWebPage.java b/DocumentConversion/CreateDocFromWebPage/src/main/java/com/datalogics/pdfl/samples/CreateDocFromWebPage.java index 1b569e76..707db757 100644 --- a/DocumentConversion/CreateDocFromWebPage/src/main/java/com/datalogics/pdfl/samples/CreateDocFromWebPage.java +++ b/DocumentConversion/CreateDocFromWebPage/src/main/java/com/datalogics/pdfl/samples/CreateDocFromWebPage.java @@ -21,9 +21,9 @@ * asset references in a local file resolve against that file's directory. The * optional second argument names the output file. * - * Rendering is performed by the WebToPDF plugin, which embeds Chromium. That - * plugin runtime ships as a separate add-on package; see pom.xml, which declares - * it and unpacks it alongside the JNI libraries. + * Rendering is performed by the WebToPDF plugin. The plugin runtime ships as a + * separate add-on package; see pom.xml, which declares it and unpacks it + * alongside the JNI libraries. * * Copyright (c) 2026, Datalogics, Inc. All rights reserved. * @@ -85,9 +85,6 @@ public static void main(String[] args) throws Throwable { System.out.println("Saved to " + output); } catch (RuntimeException e) { - // Web conversion failures surface as a plain RuntimeException: the - // interface layer's error category and plugin result code are not - // exposed to Java, so only the message text is available here. System.err.println("Conversion failed: " + e.getMessage()); System.err.println("If the plugin could not be loaded, confirm that the web " + "conversion runtime was unpacked into target/lib (see pom.xml).");